package {

	import flash.display.Sprite;
	//import flash.events.MouseEvent;
	import flash.display.Shape;
	import Letter;

	public class testSnapFunction extends Sprite {

		//private var xPos:int;
		//private var yPos:int;
		private var g_gridSpacing:int = 50;
		//private var rect:Sprite = new Sprite();
		private var letterArr:Array = new Array();

		public function testSnapFunction():void {
			drawLines();
			drawLetter("a");
			drawLetter("b");
			drawLetter("c");
		}
		private function drawLetter(nm:String):void {
			var temp:Letter = new Letter();
			temp.name = nm;
			temp.x = 50;
			this.addChild(temp);
			letterArr.push(temp);
		}
		
		public function getLetters():Array {
			return letterArr;
		}
		
		public function getClosestLetterPoint(pointArray:Array):Array {
			for (var i:uint = 0; i < stage.numChildren; i++) {
				trace('\t|\t ' +i+'.\t name:' + stage.getChildAt(i).name + 
				'\t type:' + typeof (stage.getChildAt(i))+ '\t' + stage.getChildAt(i));
			}
			var closestLetterPoint:Array = [0,0];
			return closestLetterPoint;
		}
		
		private function drawLines():void {
			var myShape:Shape = new Shape();
			myShape.graphics.lineStyle(2, 0x990000, .75);
			myShape.graphics.beginFill(0x00FF00);
			for (var i:int=0; i<20; i++) {
				myShape.graphics.moveTo(0, i*g_gridSpacing);
				myShape.graphics.lineTo(550, i*g_gridSpacing);
			}
			this.addChild(myShape);
		}
	}
}